#-------------------------------------------------------------------------------
# Name:        FileOps
# Purpose:     Containing all file data and operation functions
#
# Author:      ZXL
# Version:     1.0
# Created:     30/09/2013
# Copyright:   (c) ZXL 2013
# Licence:     <Licenced exclusively to CJ(smile) and her colleages:)>
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
def __clear_env():
    for key in globals().keys():
        if not key.startswith("__"):
            globals().pop(key)
            return
        return
    return

def readplf(fname):
# read patient information file
    fhandle = open(Patcfg.fname,'r',)
    fileall=fhandle.readlines()
    fhandle.close()
    validate(fileall)
    return fileall


def appendpatient(fname):
    return

def writeplf(fname):
    return



def resetplf(fname):
    # reset the fname to NONE when error occurs
    print("Patient information error occured!")
    resetflag=input("Reset the patient information file.Are you sure?Y/N")
    if resetflag=="Y" or resetflag=="y":
        f2write=""
        writef(fname,f2write)
    else:
        return
    return

def validate(fileall):
    a=1
    b=2
    return a,b
 
class Patcfg():
    # patient information file configurations
    fname="PatientList.txt"
    linesperpat=10


class Patient():
    
    name=""
    contact=""
    nextvisit=""
    age=0
    Gender="Male"
    Diagnosis="类风湿性关节炎"
    FisitV="2013/9/26"
    Treatment=["NSAIDS","阿司匹林"]
    VisitSCH=[3,12,14,21,22,34,21,21,21,21]
    Remark=""


if __name__ == '__main__':
    __clear_env
    fileget=readplf(Patcfg.fname)
    print("Loading patient infomation...")
    print("Loading complete!")
    print(fileget[0])
    print(fileget[1])
